package com.ccp.dev.qbdms.service;

import com.ccp.dev.core.basic.base.BaseService;
import com.ccp.dev.core.basic.util.UUIDUtils;
import com.ccp.dev.core.basic.util.ContextUtil;
import com.ccp.dev.core.basic.web.query.QueryFilter;
import com.ccp.dev.core.util.BeanUtils;
import com.ccp.dev.core.util.StringUtil;
import com.ccp.dev.core.poi.excel.Excel;
import com.ccp.dev.qbdms.model.WQbdQualityKnow;
import com.ccp.dev.qbdms.model.WQbdSoftwareproAnls;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import com.ccp.dev.qbdms.dao.WQbdMyKnowledgeDao;
import com.ccp.dev.qbdms.model.WQbdMyKnowledge;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * 我的知识 信息操作服务类
 *
 * @author hw
 * @date 2020-07-27 10:56:30
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class WQbdMyKnowledgeService extends BaseService<WQbdMyKnowledge> {

    @Resource
    private WQbdMyKnowledgeDao dao;

    public HSSFWorkbook exportExcel(Excel excel,QueryFilter queryFilter){
    List<WQbdMyKnowledge> dataList = this.dao.queryAll(queryFilter);
        int startRow = 1;
        //给每一个单元格赋值
        for (WQbdMyKnowledge data : dataList) {
        excel.cell(startRow, 0).value(data.getId());
        //excel.cell(startRow, 1).value(data.getMc());
        //可在赋值时，根据需求进行格式化
        //excel.cell(startRow, 2).value(DateFormatUtil.formatDate(data.getRq()));
        //excel.cell(startRow, 3).value(data.getSj());
        //excel.cell(startRow, 4).value(data.getTenantId());
        startRow++;
        }
        return excel.getWorkBook();
    }

    public WQbdMyKnowledge findByUserIdAndknowClassId(String knowledge_classifica,String userId) {
      return   dao.findByUserIdAndknowClassId(knowledge_classifica,userId);
    }

    public int delByUserIdAndDicId(String userId, String knowledge_classifica) {
        return   dao.delByUserIdAndDicId(knowledge_classifica,userId);
    }

    public List<WQbdMyKnowledge>  findByUserId(String userId){
        return   dao.findByUserId(userId);
    }

    /**
     * 保存接口传输的数据
     *
     * @param wQbdMyKnowledge 主表model,有子表的包含子表数据
     * @return
     */
    public int saveAll(WQbdMyKnowledge wQbdMyKnowledge) {
        return add(wQbdMyKnowledge);
    }

    /**
     * 根据主表id查询主表加子表数据
     *
     * @param id 主表id
     * @return
     */
    public WQbdSoftwareproAnls getParentAndChilden(String id) {
        return dao.getParentAndChilden(id);
    }


    public List<WQbdMyKnowledge> queryListByMap(Map<String,Object> map){
      return   dao.queryList(map);
    }
}
